package round1C.question1;

import java.io.BufferedInputStream;
import java.io.IOException;

public class Bate1
{
	private static BufferedInputStream in = new BufferedInputStream(System.in);

	public static void main(String[] args) throws IOException
	{
		int i=readInt();
		
		for(int j=1; j<=i; j++)
			System.out.println("Case #" + j + ": " + next());
	}

	private static String next() throws IOException
	{
		long i = readInt();
		long j = readInt();
		
		if(i == j)
		{
			return 0 + "";
		}
		
		long t = j;
		while(t > 2)
		{
			if(t % 2 != 0)
			{
				return "impossible";
			}
			
			t /= 2;
		}
		
		long c = common(i, j);
		
		i /= c;
		j /= c;
		
		return get(i, j, 1);
	}
	
	private static String get(long i, long j, int level)
	{
		if( j % 2 == 0)
		{
			j /= 2;
			
			if(j > i)
				return get(i, j, level + 1);
			else
				return level + "";
		}
		else
		{
			return "impossible";
		}	
	}

	private static long common(long i, long j)
	{
		if(j % i != 0)
		{
			return common(j % i, i);
		}
		else
		{
			return i;
		}
	}

	private static int readInt() throws IOException
	{
		int i,sum=0;
		
		while(((i=in.read())&48) != 48 || i>57);
		
		for(;(i&56) == 48 || (i&62) == 56; i=in.read())
			sum = sum*10 + (i&15);
		
		return sum;
	}
}
